import { configureStore, combineReducers } from "@reduxjs/toolkit";
//import { configureStore } from "@reduxjs/toolkit";
import { persistReducer, persistStore } from "redux-persist";
//import storage from "redux-persist/lib/storage";
import storage from "redux-persist/lib/storage/session";

import app from "./modules/app"
import user from "./modules/user";



const rootReducer = combineReducers({
    app: persistReducer({
        key: 'app',
        storage,
        blacklist: ["msg"],
    }, app),
    user: persistReducer(
        {
            key: "user",
            storage,
            blacklist: ['menuItems'],

        },
        user
    ),

});
const store = configureStore({
    // reducer: persistReducer({
    //     key: 'root',
    //     storage: storage,
    //     // blacklist: [],//黑名单
    //     // whitelist: [],//白名单
    // }, rootReducer),
    reducer: rootReducer,



    middleware: (getDefaultMiddleware) => {
        return getDefaultMiddleware({
            serializableCheck: false,
        });
    },
});

export type RootState = ReturnType<typeof store.getState>

export const persistor = persistStore(store)

export default store;